package com.lbssoft.gpsbd.dao;

import java.util.List;
import java.util.Map;

import org.apache.ibatis.annotations.Mapper;
import org.apache.ibatis.annotations.Param;
import org.apache.ibatis.annotations.Select;

import com.lbssoft.gpsbd.model.Command;

@Mapper
public interface CommandMapper {
	
	/**
	 * 获取命令格式集合
	 * @return
	 */
	@Select("SELECT id,name,type,view FROM lbs_commands")
	List<Command> views();
	
	/**
	 * 根据设备类型获取命令id集合
	 * @return
	 */
	@Select("SELECT typeId,group_concat(commandId) as commandIds FROM lbs_type_command  GROUP BY typeId")
	List<Map<Integer,List<Integer>>> getCommandIdsByType();

	/**
	 * 根据命令id获取命令信息
	 * @param id
	 * @return
	 */
	@Select("SELECT id,name,type,view as view FROM lbs_commands where id  = #{id}")
	Command getCommand(@Param("id") int id);
	
	
}
